package me.ereach.multi;

public class Main01CreateThread {
    public static void main(String[] args) {
        System.out.println("===Current active threads");
        System.out.println(Thread.activeCount());

        System.out.println("===available cores");
        System.out.println(Runtime.getRuntime().availableProcessors());

        System.out.println("===normal");
        for (var i = 0; i < 5; i++) {
            Thread thread = new Thread(new DownloadFileTask());
            thread.start();
        }

        System.out.println("===inner anonymous class");
        for (var i = 0; i < 5; i++) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    System.out.println("Anonymous: " + Thread.currentThread().getName());
                }
            });

            thread.start();
        }

        System.out.println("===lambda");
        for (var i = 0; i < 5; i++) {
            Thread thread = new Thread(() -> System.out.println("Lambda: " + Thread.currentThread().getName()));
            thread.start();
        }

    }
}
